<head>
    <title>添加团队</title>
    <link href="/lego/static/css/bootstrap.css" rel="stylesheet"/>
    <link href="/lego/static/css/header.css" rel="stylesheet"/>
    <link href="/lego/static/css/xcConfirm.css" rel="stylesheet"/>
    <script src="/lego/static/js/jquery.1.11.3.min.js"/></script>
    <script src = "/lego/static/js/bootstrap.js" ></script>
    <script src="/lego/static/js/underscore-min.js"></script>
    <script src="/lego/static/js/common.js"></script>
    <script src="/lego/static/js/xcConfirm.js"></script>
    <script type="text/javascript">
        $(function () {
            $.ajax({
                url: '/lego/getNextTeamId',
                type: 'GET',
                success: function (data) {
                    if (data && data.code == 200) {
                        $('#teamId').val(data.data);
                    }
                }
            });

            $("#addTeamBtn").click(function(){
                //参数校验
                var formJson = $("#teamForm").toJSON();
                var inputTeamName = formJson["teamName"];
                if(inputTeamName == ""){
                    window.wxc.xcConfirm("团队名称不能为空!!!", window.wxc.xcConfirm.typeEnum.error);
                    return;
                }
                $.ajax({
                    url: '/lego/addTeam',
                    type: 'POST',
                    data:$("#teamForm").toJSONString(),
                    contentType:'application/json;charset=UTF-8',
                    success: function (data) {
                        if (data && data.code == 200) {
                            var op = {
                                title: "提示信息",
                                btn: window.wxc.xcConfirm.btnEnum.ok,
                            }
                            if(data.msg == "添加成功"){
                                window.wxc.xcConfirm(data.msg,window.wxc.xcConfirm.typeEnum.success, op);
                            }else {
                                window.wxc.xcConfirm(data.msg,window.wxc.xcConfirm.typeEnum.error, op);
                            }
                        }
                    }
                });
            });
        });
    </script>
</head>
<body>
    <#include "../navigationBar.ftl">
    <header class="jumbotron subhead" id="overview">
        <div class="container">
            <h1>QA团队管理</h1>
            <h5>所有操作的第一步,先加入你的团队吧!!!</h5>
        </div>
    </header>

    <form method="post" action="/lego/addTeam" class="form-horizontal" id="teamForm">
        <div class="form-group">
            <label for="teamId" class="col-sm-4 control-label">团队编号</label>
            <div class="col-sm-4">
                <input type="text" class="form-control " readonly="readonly" name="teamId" id="teamId">
            </div>
        </div>
        <div class="form-group">
            <label for="teamName" class="col-sm-4 control-label">团队名称</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="teamName">
            </div>
        </div>

        <div class="text-center">
            <button class="btn btn-success" type="button" id="addTeamBtn">
                <span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存
            </button>
            <a class="btn btn-primary" href="/lego/teamListIndex">
                <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span>返回列表
            </a>
        </div>
    </form>
</body>
